home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / scrollkeeper / stylesheets / toc.xsl < prev   
Encoding:
Extensible Markup Language  |  2007-03-09  |  5.4 KB  |  178 lines

  1. <?xml version='1.0'?>
  2. <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
  3.  
  4. <!-- copyright (C) 2001 Sun Microsystems, Inc.  -->
  5.  
  6. <xsl:template match="/">
  7.     <toc>
  8.     <xsl:text> </xsl:text>
  9.         <xsl:apply-templates select="book[@id]|part|article[@id]|reference"> 
  10.         <xsl:with-param name="toclevel" select="0"/>
  11.     </xsl:apply-templates>
  12.     </toc>
  13. </xsl:template>
  14.  
  15. <xsl:template match="book">
  16.     <xsl:param name="toclevel"/>
  17.         <xsl:apply-templates select="article[@id]|chapter[@id]|appendix[@id]|part[@id]">
  18.         <xsl:with-param name="toclevel" select="$toclevel+1"/>
  19.     </xsl:apply-templates>
  20. </xsl:template>
  21.  
  22. <xsl:template match="reference">
  23.     <xsl:param name="toclevel"/>
  24.     <xsl:apply-templates select="refentry[@id]">
  25.         <xsl:with-param name="toclevel" select="$toclevel+1"/>
  26.     </xsl:apply-templates>
  27. </xsl:template>
  28.  
  29. <!--    match part in two different ways - making "id-less" parts skip a level,
  30.     mimicking it all having been an article. 
  31. -->
  32.  
  33. <xsl:template match="part">
  34.     <xsl:param name="toclevel"/>
  35.     <xsl:apply-templates select="chapter[@id]/sect1[@id]">
  36.         <xsl:with-param name="toclevel" select="$toclevel+1"/>
  37.     </xsl:apply-templates>
  38. </xsl:template>
  39.  
  40. <xsl:template match="part[@id]">
  41.     <xsl:param name="toclevel"/>
  42.     <xsl:element name="tocsect{$toclevel}">
  43.         <xsl:attribute name="linkid">
  44.             <xsl:value-of select="@id"/>
  45.         </xsl:attribute>
  46.         <xsl:value-of select="title"/>
  47.         <xsl:text> </xsl:text>
  48.         <xsl:apply-templates select="appendix[@id]|article[@id]|chapter[@id]">
  49.             <xsl:with-param name="toclevel" select="$toclevel+1"/>
  50.         </xsl:apply-templates>
  51.     </xsl:element>
  52.     <xsl:text> </xsl:text>
  53. </xsl:template>
  54.  
  55. <xsl:template match="article">
  56.     <xsl:param name="toclevel"/>
  57.          <xsl:apply-templates select="sect1[@id]|appendix[@id]">
  58.         <xsl:with-param name="toclevel" select="$toclevel+1"/>
  59.     </xsl:apply-templates>
  60. </xsl:template>
  61.  
  62. <xsl:template match="appendix">
  63.     <xsl:param name="toclevel"/>
  64.     <xsl:element name="tocsect{$toclevel}">
  65.         <xsl:attribute name="linkid">
  66.                         <xsl:value-of select="@id"/>
  67.                 </xsl:attribute>
  68.             <xsl:value-of select="title"/>
  69.         <xsl:text> </xsl:text>
  70.             <xsl:apply-templates select="sect1[@id]">
  71.             <xsl:with-param name="toclevel" select="$toclevel+1"/>
  72.             </xsl:apply-templates>
  73.     </xsl:element>
  74.     <xsl:text> </xsl:text>
  75.   </xsl:template>
  76.  
  77. <xsl:template match="chapter">
  78.     <xsl:param name="toclevel"/>
  79.     <xsl:element name="tocsect{$toclevel}">
  80.         <xsl:attribute name="linkid">
  81.                         <xsl:value-of select="@id"/>
  82.                 </xsl:attribute>
  83.             <xsl:value-of select="title"/>
  84.         <xsl:text> </xsl:text>
  85.             <xsl:apply-templates select="sect1[@id]">
  86.             <xsl:with-param name="toclevel" select="$toclevel+1"/>
  87.             </xsl:apply-templates>
  88.     </xsl:element>
  89.     <xsl:text> </xsl:text>
  90. </xsl:template>
  91.  
  92. <xsl:template match="sect1">
  93.     <xsl:param name="toclevel"/>
  94.     <xsl:element name="tocsect{$toclevel}">
  95.         <xsl:attribute name="linkid">
  96.                         <xsl:value-of select="@id"/>
  97.                 </xsl:attribute>
  98.         <xsl:value-of select="title"/>
  99.         <xsl:text> </xsl:text>
  100.         <xsl:apply-templates select="sect2[@id]">
  101.             <xsl:with-param name="toclevel" select="$toclevel+1"/>
  102.             </xsl:apply-templates>
  103.     </xsl:element>
  104.     <xsl:text> </xsl:text>
  105. </xsl:template>
  106.  
  107. <xsl:template match="sect2">
  108.     <xsl:param name="toclevel"/>
  109.     <xsl:element name="tocsect{$toclevel}">
  110.         <xsl:attribute name="linkid">
  111.                         <xsl:value-of select="@id"/>
  112.                 </xsl:attribute>
  113.                <xsl:value-of select="title"/>
  114.         <xsl:text> </xsl:text>
  115.                <xsl:apply-templates select="sect3[@id]">
  116.             <xsl:with-param name="toclevel" select="$toclevel+1"/>
  117.             </xsl:apply-templates>
  118.     </xsl:element>
  119.     <xsl:text> </xsl:text>
  120. </xsl:template>
  121.  
  122. <xsl:template match="sect3">
  123.     <xsl:param name="toclevel"/>
  124.     <xsl:element name="tocsect{$toclevel}">
  125.         <xsl:attribute name="linkid">
  126.                         <xsl:value-of select="@id"/>
  127.                 </xsl:attribute>
  128.                <xsl:value-of select="title"/>
  129.         <xsl:text> </xsl:text>
  130.                <xsl:apply-templates select="sect4[@id]">
  131.             <xsl:with-param name="toclevel" select="$toclevel+1"/>
  132.             </xsl:apply-templates>
  133.     </xsl:element>
  134.     <xsl:text> </xsl:text>
  135. </xsl:template>
  136.  
  137. <xsl:template match="sect4">
  138.     <xsl:param name="toclevel"/>
  139.     <xsl:element name="tocsect{$toclevel}">
  140.         <xsl:attribute name="linkid">
  141.                         <xsl:value-of select="@id"/>
  142.                 </xsl:attribute>
  143.                <xsl:value-of select="title"/>
  144.         <xsl:text> </xsl:text>
  145.         <xsl:apply-templates select="sect5[@id]">
  146.             <xsl:with-param name="toclevel" select="$toclevel+1"/>
  147.             </xsl:apply-templates>
  148.     </xsl:element>
  149.     <xsl:text> </xsl:text>
  150. </xsl:template>
  151.  
  152. <xsl:template match="sect5">
  153.     <xsl:param name="toclevel"/>
  154.     <xsl:element name="tocsect{$toclevel}">
  155.         <xsl:attribute name="linkid">
  156.                         <xsl:value-of select="@id"/>
  157.                 </xsl:attribute>
  158.                <xsl:value-of select="title"/>
  159.         <xsl:text> </xsl:text>
  160.     </xsl:element>
  161.     <xsl:text> </xsl:text>
  162. </xsl:template>
  163.   
  164. <xsl:template match="refentry">
  165.     <xsl:param name="toclevel"/>
  166.     <xsl:element name="tocsect{$toclevel}">
  167.         <xsl:attribute name="linkid">
  168.                         <xsl:value-of select="@id"/>
  169.                 </xsl:attribute>
  170.                <xsl:value-of select="refmeta/refentrytitle"/>
  171.                <!-- <xsl:value-of select="@id"/> -->
  172.         <xsl:text> </xsl:text>
  173.     </xsl:element>
  174.         <xsl:text> </xsl:text>
  175. </xsl:template>
  176.   
  177. </xsl:stylesheet>
  178.